home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: undoChangeSmallObjHdr.c,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:56:03 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
-
- #include "sysdefs.h"
- #include "ess.h"
- #include "checking.h"
- #include "trace.h"
- #include "error.h"
- #include "list.h"
- #include "tid.h"
- #include "io.h"
- #include "lock.h"
- #include "object.h"
- #include "msgdefs.h"
- #include "thread.h"
- #include "latch.h"
- #include "semaphore.h"
- #include "link.h"
- #include "lsn.h"
- #include "bf.h"
- #include "pool.h"
- #include "log.h"
- #include "volume.h"
- #include "trans.h"
- #include "openlog.h"
- #include "logrecs.h"
- #include "logaction.h"
- #include "undo.h"
- #include "undo_extfuncs.h"
- #include "bf_extfuncs.h"
- #include "log_extfuncs.h"
- #include "util_funcs.h"
- #include "log_intfuncs.h"
- #include "thread_globals.h"
- #include "bf_globals.h"
- #include "trans_globals.h"
- #include "sm_macro.h"
- #ifdef INIT_LRC_IS_LSN
- # include "log_globals.h"
- #endif
-
-
- void
- undoChangeSmallObjHdr (
-
- LOGRECORDHDR *recordHeader
- )
- {
-
- GROUPLINK *groupLink;
- SLOTTEDPAGE *slottedPage;
- PID *pid;
- OBJHDR *logObjHdr;
- SMALLOBJ *origObj;
- PAGESLOT *slotPtr;
- OID *oid;
- LOGRECORDINFO recordInfo;
- #ifdef INIT_LRC_IS_LSN
- LRC tempLRC;
- LRC *lrc = &tempLRC;
- #else
- LRC *lrc;
- #endif /* INIT_LRC_IS_LSN; */
- LSN lsn;
- FORCEMARK forceMark;
- BOOL actionDone; /* Indicates whether the action
- was ever performed on the page */
- INIT_MISSING_UPDATE_INFO( Active->transRec );
-
- TRPRINT(TR_IO, TR_LEVEL_1, ("lsn:%d", recordHeader->recordLSN));
-
- /*
- * get a pointer to the page for the record
- */
- pid = &(recordHeader->actionPid);
- TRPRINT(TR_IO|TR_LOG, TR_LEVEL_2, ("pid:%d", pid->page));
-
- /*
- * get pointer to oid, and the old object header
- */
- oid = (OID*) GET_LOG_IMAGE(recordHeader, 0);
- logObjHdr = (OBJHDR*) GET_LOG_IMAGE(recordHeader, 2);
-
- /*
- * read in the page
- */
- if ((groupLink = bf_ReadPage(UserBufGroup, pid, SLOTTED_PAGE2SIZE, BF_SEM)) == NULL) {
-
- SM_ERROR(TYPE_FATAL, Active->errno);
- }
- groupLink->pageHash->pageType = PAGE_SLOTTED;
-
- /*
- * get a pointer to the slotted page
- */
- slottedPage = (SLOTTEDPAGE *) groupLink->bufFrame;
- if (CHECK_SLOTTED_MAGIC(slottedPage)) {
- SM_ERROR(TYPE_FATAL, Active->errno);
- }
-
- /*
- * See if the action was actually done
- */
- actionDone = compareLRC(&(recordHeader->actionLRC), &(slottedPage->header.lrc) ) <= 0;
-
- /*
- * it is possible that the action
- * never made it to the page on the server, so missing update
- * information may need to be recordedjj
- *
- * Process any missing updates, and return a pointer to
- * the lrc to increment. This will either be the lrc on the
- * slotted page, or the lrc in the missingUpdatePageTable
- */
- RECORD_MISSING_UPDATE( actionDone, &lrc, missingUpdateInfo, pid,
- &(slottedPage->header.lrc),
- groupLink->pageHash, recordHeader, PAGE_SLOTTED);
-
- /*
- * increment the lrc on the page
- */
- GENERATE_LRC(lrc);
-
- /*
- * Log the undo create
- */
- recordInfo.action = LOG_ACTION_CHANGE_SMALL_OBJHDR;
- recordInfo.type = LOG_REC_TYPE_COMPENSATION;
- recordInfo.imageCount = 2;
- recordInfo.actionPid = pid;
- recordInfo.actionLRC = lrc;
- recordInfo.imageSize[0] = sizeof(OID);
- recordInfo.imageData[0] = (VOID *) oid;
- recordInfo.imageSize[1] = sizeof(OBJHDR);
- recordInfo.imageData[1] = (VOID *) logObjHdr;
- recordInfo.nextUndoLSN = recordHeader->previousLSN;
- recordInfo.flags = NOFLAGS;
-
- /*
- * write the record to the log
- */
- if ((forceMark = writeLogRecord((TRANSREC *) Active->transRec, &recordInfo,
- &lsn, NOFLAGS)) < 0) {
- SM_ERROR(TYPE_FATAL, Active->errno);
- }
-
- /*
- * mark the page dependency
- */
- #ifndef INIT_LRC_IS_LSN
- DEPEND_LOG(groupLink->pageHash, forceMark, &lsn, lrc);
- #endif
-
- /*
- * perform the undo by copying the old data
- * if action was performed
- */
- if (actionDone) {
-
- #ifdef INIT_LRC_IS_LSN
- DEPEND_LOG(groupLink->pageHash, forceMark, &lsn, lrc);
- #endif
-
- /*
- * Get a pointer to the slot and then the object
- */
- SM_ASSERT(LEVEL_3, oid->diskAddr.slot < slottedPage->header.slotCount);
- slotPtr = GETSLOTPTR(slottedPage, oid->diskAddr.slot);
- SM_ASSERT(LEVEL_3, oid->diskAddr.unique == slotPtr->unique);
- origObj = GETOBJECTPTR(slottedPage, slotPtr);
-
- /*
- * Undo the header change
- */
- origObj->objectHdr = *logObjHdr;
-
- }
-
- /*
- * signal the semaphore and unfix the page, dirty the page if the
- * action was done
- */
- signalSemaphore( &(groupLink->pageHash->semaphore) );
- bf_UnfixPage(groupLink, BF_DEFAULT, actionDone);
-
- /*
- * return success
- */
- return;
- }
-